<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-table stripe :data="authorityList" border>
        <el-table-column type="index" label="序号" width="80"></el-table-column>

        <el-table-column prop="authName" label="权限名称"></el-table-column>

        <el-table-column prop="path" label="路径"></el-table-column>

        <el-table-column prop="level" label="等级">
          <template v-slot="scope">
            <el-tag v-if="scope.row.level == 0">标签一</el-tag>
            <el-tag v-else-if="scope.row.level == 1" type="success">标签二</el-tag>
            <el-tag v-else-if="scope.row.level == 2" type="warning">标签三</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import request from '@/util/request'
import { ElMessage } from 'element-plus'
import { onMounted, ref } from 'vue'
let authorityList = ref([])
const getRightList = async () => {
  const { data, meta } = await request({
    url: 'rights/list',
    method: 'GET',
  })
  if (meta.status !== 200) {
    return ElMessage.error('网络异常,稍后重试')
  }
  authorityList.value = data
  ElMessage.success('获取成功')
}
onMounted(() => {
  getRightList()
})
</script>

<style scoped>
.el-card {
  margin-top: 20px;
}
</style>
